package com.formation.tocea.library.client.listener;

import com.formation.tocea.library.client.ui.form.LoginForm;
import com.formation.tocea.library.client.ui.main.Menu;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;

public class LoginLogoutListener implements ClickHandler {
	public void onClick(ClickEvent event) {
		Menu menu = (Menu) RootPanel.get("menu").getWidget(0);
		Button loginButton =(Button)event.getSource();
		
		if (loginButton.getText().equals("Se connecter")) {
			loginButton.setEnabled(false);
			menu.insert(new LoginForm(), 1);
		}
		else {
			menu.setDisconnectedMode();
			loginButton.setText("Se connecter");
		}
	}
}
